<template>
  <div>
      <form action="/" v-if="$route.meta.isActive">
  <van-search 
    v-model="value"
    show-action
    placeholder="请输入搜索关键词"
    @search="onSearch"
    @cancel="onCancel"
    @click="$route.path == '/search'?'':$router.push('/search') "
  >
  <template #action >

   
    <!-- {{$store.state.userInfo ? $store.state.userInfo.user:'未登陆'}} -->
    <div class="status">
      <!-- 判断是否在搜索页面 -->
      <div v-if="$route.path == '/search'">
        <button>确定</button>
      </div>
      <div v-else>
         <!-- 已登陆状态 -->
      <div v-if="$store.state.userInfo && $route.path != '/search' "> 
        <i class="cc- cc-wode"><span class="loginName">{{$store.state.userInfo.user}}</span></i>
        
      </div>
      <!-- 未登录 -->
      <!-- <div v-show="!$store.state.userInfo"> -->
      <div v-else @click="$router.push('/login')">
        <i class="cc- cc-wode"><span>未登录</span></i>
      </div>

      </div>
     
    </div>

  </template>
  </van-search>
  
  </form>
  <div v-else class="header"><i class="cc- cc-fanhui navtitle" @click="$router.back()"></i><span>{{$route.name}}</span></div>
  </div>
</template>

<script>
export default {
    name:'Search',
    data(){
        return{
            value:''
        }
    },
    methods:{
      onSearch(val) {
      this.$toast(val);
    },
    onCancel() {
      this.$toast('取消');
    },
  
    }
}
</script>

<style lang="less" scoped>
.header{
  height: 90px;
  background-color:#ffffff;
  padding: 10px 0 10px 12px;
  
  line-height: 90px;
  div{
    display: inline-block;
  }
  span{
  text-align: center;
  font-size: 40px;
  margin: 0 235px;
 
  } 
  .navtitle{
    padding: 0 0 50px 30px;
    font-size: 42px;
  }
  
}


  
.cc-{
  
    color: var(--themeColor);
    padding: 0 10px;
    font-size: 30px ;
    span{
      width: 50px;
      white-space: nowrap;
      text-overflow: ellipsis;
      
      padding: 0 10px;
    }
  }

  
</style>